package cx.zan.web.filter;

import cx.zan.utils.RRHolder;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/3/30 22:41
 */
@WebFilter("/*")
public class RRFilter implements Filter {
    @Override
    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        //帮response对象 放到某个地方去
        RRHolder.setResponse((HttpServletResponse) resp);
        RRHolder.setRequest((HttpServletRequest) req);
        chain.doFilter(req, resp);
    }

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

}
